<?php

use think\migration\Migrator;
use think\migration\db\Column;

class CreateAdminLogTable extends Migrator
{
    /**
     * Migrate Up.
     */
    public function up()
    {
        $table = $this->table('admin_log', ['comment' => '管理员日志', 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci']);
        $table->addColumn('admin_id', 'integer', ['limit'  =>  11, 'default' => 0, 'comment' => '管理员'])
            ->addColumn('account', 'string', ['limit'  =>  60, 'null' => true, 'default' => null, 'comment' => '管理员用户名'])
            ->addColumn('nickname', 'string', ['limit'  =>  60, 'null' => true, 'default' => null, 'comment' => '管理员昵称'])
            ->addColumn('url', 'string', ['limit'  =>  255, 'null' => true, 'default' => null, 'comment' => '访问地址'])
            ->addColumn('params', 'text', ['null' => true, 'default' => null, 'comment' => '参数'])
            ->addColumn('description', 'string', ['limit' => 255, 'null' => true, 'default' => null, 'comment' => '描述'])
            ->addColumn('ip', 'string', ['limit'  =>  20, 'null' => true, 'default' => null, 'comment' => '访问ip'])
            ->addColumn('useragent', 'string', ['limit'  =>  255, 'null' => true, 'default' => null, 'comment' => 'ip'])
            ->addColumn('create_time', 'integer', ['limit'  =>  10, 'null' => true, 'default' => null, 'comment' => '创建时间'])
            ->addIndex('admin_id')
            ->addIndex('account')
            ->create();
    }

    /**
     * Migrate Down.
     */
    public function down()
    {
        $table = $this->table('admin_log');
        $table->drop();
    }
}
